/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package respaldomysql;

import java.util.ArrayList;
import java.util.logging.Level;
import java.util.logging.Logger;
import org.w3c.dom.*;
import javax.xml.parsers.*;
import javax.xml.transform.*;
import javax.xml.transform.dom.*;
import javax.xml.transform.stream.*;
/**
 *
 * @author Lolo
 */
public class FrmConfiguracion extends javax.swing.JInternalFrame {

    private DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
    private DocumentBuilder builder;
    private DOMImplementation implementation;
    private Document document;
    private Element raiz;
    private ArrayList<Respaldo> respaldos;
    private boolean guardar = true;
    /**
     * Creates new form FrmConfiguracion
     */
    public FrmConfiguracion(ArrayList<Respaldo> respaldos) {
        initComponents();
        this.respaldos = respaldos;
        cargarGrid();
    }

    private void cargarGrid(){
        jDataTable1.addColumn("ID");
        jDataTable1.addColumn("Directorio");
        jDataTable1.addColumn("Hora");
        jDataTable1.addColumn("DB");
        jDataTable1.addColumn("U");
        jDataTable1.addColumn("P");
        jDataTable1.addColumn("Server");
        
        for (int i = 0; i < respaldos.size(); i++) {
            jDataTable1.addRow(
                    new Object[]{
                        Integer.toString(respaldos.get(i).getId()),
                        respaldos.get(i).getDirectorio(),
                        respaldos.get(i).getHora(),
                        respaldos.get(i).getBd(),
                        respaldos.get(i).getUsuario(),
                        respaldos.get(i).getPassword(),
                        respaldos.get(i).getHost()});  
            
            System.out.println("resp: " + respaldos.get(i).getId() + " " +
                        respaldos.get(i).getDirectorio() + " " +
                        respaldos.get(i).getHora() + " " +
                        respaldos.get(i).getBd() + " " +
                        respaldos.get(i).getUsuario() + " " +
                        respaldos.get(i).getPassword() + " " +
                        respaldos.get(i).getHost());
        }
    }
    
    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jScrollPane1 = new javax.swing.JScrollPane();
        jTable1 = new javax.swing.JTable();
        lbDirectorio = new javax.swing.JLabel();
        tbxDirectorio = new javax.swing.JTextField();
        lbDirectorio1 = new javax.swing.JLabel();
        tbxHost = new javax.swing.JTextField();
        lbDirectorio2 = new javax.swing.JLabel();
        tbxUsuario = new javax.swing.JTextField();
        lbDirectorio3 = new javax.swing.JLabel();
        tbxBD = new javax.swing.JTextField();
        lbDirectorio4 = new javax.swing.JLabel();
        tbxHora = new javax.swing.JTextField();
        lbDirectorio5 = new javax.swing.JLabel();
        tbxPassword = new javax.swing.JTextField();
        lbDirectorio6 = new javax.swing.JLabel();
        btnNuevo = new javax.swing.JButton();
        jInternalFrame1 = new javax.swing.JInternalFrame();
        jScrollPane3 = new javax.swing.JScrollPane();
        jTable3 = new javax.swing.JTable();
        lbDirectorio7 = new javax.swing.JLabel();
        tbxDirectorio6 = new javax.swing.JTextField();
        lbDirectorio8 = new javax.swing.JLabel();
        tbxDirectorio7 = new javax.swing.JTextField();
        lbDirectorio9 = new javax.swing.JLabel();
        tbxDirectorio8 = new javax.swing.JTextField();
        lbDirectorio10 = new javax.swing.JLabel();
        tbxDirectorio9 = new javax.swing.JTextField();
        lbDirectorio11 = new javax.swing.JLabel();
        tbxDirectorio10 = new javax.swing.JTextField();
        lbDirectorio12 = new javax.swing.JLabel();
        tbxDirectorio11 = new javax.swing.JTextField();
        lbDirectorio13 = new javax.swing.JLabel();
        jButton2 = new javax.swing.JButton();
        btnCancelar = new javax.swing.JButton();
        btnModificar = new javax.swing.JButton();
        btnGuardar = new javax.swing.JButton();
        btnEliminar = new javax.swing.JButton();
        jScrollPane4 = new javax.swing.JScrollPane();
        jDataTable1 = new respaldomysql.jDataTable();
        tbxID = new javax.swing.JTextField();

        jTable1.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null}
            },
            new String [] {
                "Title 1", "Title 2", "Title 3", "Title 4"
            }
        ));
        jScrollPane1.setViewportView(jTable1);

        setClosable(true);

        lbDirectorio.setText("Directorio");

        tbxDirectorio.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                tbxDirectorioActionPerformed(evt);
            }
        });

        lbDirectorio1.setText("Host");

        tbxHost.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                tbxHostActionPerformed(evt);
            }
        });

        lbDirectorio2.setText("Usuario");

        tbxUsuario.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                tbxUsuarioActionPerformed(evt);
            }
        });

        lbDirectorio3.setText("BD");

        tbxBD.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                tbxBDActionPerformed(evt);
            }
        });

        lbDirectorio4.setText("Hora");

        tbxHora.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                tbxHoraActionPerformed(evt);
            }
        });

        lbDirectorio5.setText("Password");

        tbxPassword.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                tbxPasswordActionPerformed(evt);
            }
        });

        lbDirectorio6.setText("hh:mm");

        btnNuevo.setText("Nuevo");
        btnNuevo.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnNuevoActionPerformed(evt);
            }
        });

        jTable3.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null}
            },
            new String [] {
                "Title 1", "Title 2", "Title 3", "Title 4"
            }
        ));
        jScrollPane3.setViewportView(jTable3);
        jTable3.getColumnModel().getColumn(3).setResizable(false);

        lbDirectorio7.setText("Directorio");

        tbxDirectorio6.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                tbxDirectorio6ActionPerformed(evt);
            }
        });

        lbDirectorio8.setText("Host");

        tbxDirectorio7.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                tbxDirectorio7ActionPerformed(evt);
            }
        });

        lbDirectorio9.setText("Usuario");

        tbxDirectorio8.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                tbxDirectorio8ActionPerformed(evt);
            }
        });

        lbDirectorio10.setText("BD");

        tbxDirectorio9.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                tbxDirectorio9ActionPerformed(evt);
            }
        });

        lbDirectorio11.setText("Hora");

        tbxDirectorio10.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                tbxDirectorio10ActionPerformed(evt);
            }
        });

        lbDirectorio12.setText("Password");

        tbxDirectorio11.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                tbxDirectorio11ActionPerformed(evt);
            }
        });

        lbDirectorio13.setText("hh:mm");

        jButton2.setText("jButton1");

        javax.swing.GroupLayout jInternalFrame1Layout = new javax.swing.GroupLayout(jInternalFrame1.getContentPane());
        jInternalFrame1.getContentPane().setLayout(jInternalFrame1Layout);
        jInternalFrame1Layout.setHorizontalGroup(
            jInternalFrame1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jInternalFrame1Layout.createSequentialGroup()
                .addGap(20, 20, 20)
                .addGroup(jInternalFrame1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jInternalFrame1Layout.createSequentialGroup()
                        .addComponent(lbDirectorio9)
                        .addGap(18, 18, 18)
                        .addComponent(tbxDirectorio8, javax.swing.GroupLayout.PREFERRED_SIZE, 127, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(jInternalFrame1Layout.createSequentialGroup()
                        .addComponent(lbDirectorio8)
                        .addGap(32, 32, 32)
                        .addComponent(tbxDirectorio7, javax.swing.GroupLayout.PREFERRED_SIZE, 127, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(jInternalFrame1Layout.createSequentialGroup()
                        .addComponent(lbDirectorio7)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(tbxDirectorio6, javax.swing.GroupLayout.PREFERRED_SIZE, 127, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addGap(72, 72, 72)
                .addGroup(jInternalFrame1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jInternalFrame1Layout.createSequentialGroup()
                        .addComponent(lbDirectorio12)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(tbxDirectorio11, javax.swing.GroupLayout.PREFERRED_SIZE, 127, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(jInternalFrame1Layout.createSequentialGroup()
                        .addGroup(jInternalFrame1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(lbDirectorio11)
                            .addComponent(lbDirectorio10))
                        .addGap(27, 27, 27)
                        .addGroup(jInternalFrame1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(jInternalFrame1Layout.createSequentialGroup()
                                .addComponent(tbxDirectorio10, javax.swing.GroupLayout.PREFERRED_SIZE, 127, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(lbDirectorio13))
                            .addComponent(tbxDirectorio9, javax.swing.GroupLayout.PREFERRED_SIZE, 127, javax.swing.GroupLayout.PREFERRED_SIZE))))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
            .addGroup(jInternalFrame1Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jInternalFrame1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jScrollPane3)
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jInternalFrame1Layout.createSequentialGroup()
                        .addGap(0, 0, Short.MAX_VALUE)
                        .addComponent(jButton2)
                        .addGap(214, 214, 214)))
                .addContainerGap())
        );
        jInternalFrame1Layout.setVerticalGroup(
            jInternalFrame1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jInternalFrame1Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jScrollPane3, javax.swing.GroupLayout.PREFERRED_SIZE, 0, Short.MAX_VALUE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(jInternalFrame1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(lbDirectorio7)
                    .addComponent(tbxDirectorio6, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(lbDirectorio10)
                    .addComponent(tbxDirectorio9, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(jInternalFrame1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(lbDirectorio8)
                    .addComponent(tbxDirectorio7, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(lbDirectorio11)
                    .addComponent(tbxDirectorio10, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(lbDirectorio13))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(jInternalFrame1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(lbDirectorio9)
                    .addComponent(tbxDirectorio8, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(lbDirectorio12)
                    .addComponent(tbxDirectorio11, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(18, 18, 18)
                .addComponent(jButton2)
                .addGap(8, 8, 8))
        );

        btnCancelar.setText("Cancelar");
        btnCancelar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnCancelarActionPerformed(evt);
            }
        });

        btnModificar.setText("Modificar");
        btnModificar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnModificarActionPerformed(evt);
            }
        });

        btnGuardar.setText("Guardar");
        btnGuardar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnGuardarActionPerformed(evt);
            }
        });

        btnEliminar.setText("Eliminar");
        btnEliminar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnEliminarActionPerformed(evt);
            }
        });

        jDataTable1.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {
                {},
                {},
                {},
                {},
                {}
            },
            new String [] {

            }
        ));
        jDataTable1.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                jDataTable1MouseClicked(evt);
            }
        });
        jScrollPane4.setViewportView(jDataTable1);

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jScrollPane4, javax.swing.GroupLayout.Alignment.TRAILING)
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(layout.createSequentialGroup()
                                .addContainerGap()
                                .addComponent(btnEliminar)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                .addComponent(btnNuevo)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(btnCancelar)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(btnModificar)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED))
                            .addGroup(layout.createSequentialGroup()
                                .addGap(20, 20, 20)
                                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addGroup(layout.createSequentialGroup()
                                        .addComponent(lbDirectorio2)
                                        .addGap(18, 18, 18)
                                        .addComponent(tbxUsuario, javax.swing.GroupLayout.PREFERRED_SIZE, 127, javax.swing.GroupLayout.PREFERRED_SIZE))
                                    .addGroup(layout.createSequentialGroup()
                                        .addComponent(lbDirectorio1)
                                        .addGap(32, 32, 32)
                                        .addComponent(tbxHost, javax.swing.GroupLayout.PREFERRED_SIZE, 127, javax.swing.GroupLayout.PREFERRED_SIZE))
                                    .addGroup(layout.createSequentialGroup()
                                        .addComponent(lbDirectorio)
                                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                        .addComponent(tbxDirectorio, javax.swing.GroupLayout.PREFERRED_SIZE, 127, javax.swing.GroupLayout.PREFERRED_SIZE)))
                                .addGap(72, 72, 72)
                                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addGroup(layout.createSequentialGroup()
                                        .addComponent(lbDirectorio5)
                                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                        .addComponent(tbxPassword, javax.swing.GroupLayout.PREFERRED_SIZE, 127, javax.swing.GroupLayout.PREFERRED_SIZE))
                                    .addGroup(layout.createSequentialGroup()
                                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                            .addComponent(lbDirectorio4)
                                            .addComponent(lbDirectorio3))
                                        .addGap(27, 27, 27)
                                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                            .addGroup(layout.createSequentialGroup()
                                                .addComponent(tbxHora, javax.swing.GroupLayout.PREFERRED_SIZE, 127, javax.swing.GroupLayout.PREFERRED_SIZE)
                                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                                .addComponent(lbDirectorio6))
                                            .addComponent(tbxBD, javax.swing.GroupLayout.PREFERRED_SIZE, 127, javax.swing.GroupLayout.PREFERRED_SIZE))))
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 11, Short.MAX_VALUE)))
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                            .addComponent(btnGuardar, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                            .addComponent(tbxID))))
                .addContainerGap())
            .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(layout.createSequentialGroup()
                    .addGap(0, 291, Short.MAX_VALUE)
                    .addComponent(jInternalFrame1, javax.swing.GroupLayout.PREFERRED_SIZE, 0, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addGap(0, 291, Short.MAX_VALUE)))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addComponent(jScrollPane4, javax.swing.GroupLayout.PREFERRED_SIZE, 171, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(18, 18, 18)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(lbDirectorio)
                    .addComponent(tbxDirectorio, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(lbDirectorio3)
                    .addComponent(tbxBD, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(lbDirectorio1)
                    .addComponent(tbxHost, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(lbDirectorio4)
                    .addComponent(tbxHora, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(lbDirectorio6))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(lbDirectorio2)
                    .addComponent(tbxUsuario, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(lbDirectorio5)
                    .addComponent(tbxPassword, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(tbxID, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(18, 18, 18)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(btnNuevo)
                    .addComponent(btnCancelar)
                    .addComponent(btnModificar)
                    .addComponent(btnGuardar)
                    .addComponent(btnEliminar))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
            .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(layout.createSequentialGroup()
                    .addGap(0, 162, Short.MAX_VALUE)
                    .addComponent(jInternalFrame1, javax.swing.GroupLayout.PREFERRED_SIZE, 0, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addGap(0, 161, Short.MAX_VALUE)))
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void tbxDirectorioActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_tbxDirectorioActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_tbxDirectorioActionPerformed

    private void tbxHostActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_tbxHostActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_tbxHostActionPerformed

    private void tbxUsuarioActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_tbxUsuarioActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_tbxUsuarioActionPerformed

    private void tbxBDActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_tbxBDActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_tbxBDActionPerformed

    private void tbxHoraActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_tbxHoraActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_tbxHoraActionPerformed

    private void tbxPasswordActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_tbxPasswordActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_tbxPasswordActionPerformed

    private void tbxDirectorio6ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_tbxDirectorio6ActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_tbxDirectorio6ActionPerformed

    private void tbxDirectorio7ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_tbxDirectorio7ActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_tbxDirectorio7ActionPerformed

    private void tbxDirectorio8ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_tbxDirectorio8ActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_tbxDirectorio8ActionPerformed

    private void tbxDirectorio9ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_tbxDirectorio9ActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_tbxDirectorio9ActionPerformed

    private void tbxDirectorio10ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_tbxDirectorio10ActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_tbxDirectorio10ActionPerformed

    private void tbxDirectorio11ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_tbxDirectorio11ActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_tbxDirectorio11ActionPerformed

    private void btnGuardarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnGuardarActionPerformed
        if(guardar){
            jDataTable1.addRow(new Object[]{
                                tbxID.getText(),
                                tbxDirectorio.getText(),
                                tbxHora.getText(),
                                tbxBD.getText(),
                                tbxUsuario.getText(),
                                tbxPassword.getText(),
                                tbxHost.getText()});
        }else{
            jDataTable1.setValueAt(tbxID.getText(), jDataTable1.getSelectedRow(), 0);
            jDataTable1.setValueAt(tbxDirectorio.getText(), jDataTable1.getSelectedRow(), 1);
            jDataTable1.setValueAt(tbxHora.getText(), jDataTable1.getSelectedRow(), 2);
            jDataTable1.setValueAt(tbxBD.getText(), jDataTable1.getSelectedRow(), 3);
            jDataTable1.setValueAt(tbxUsuario.getText(), jDataTable1.getSelectedRow(), 4);
            jDataTable1.setValueAt(tbxPassword.getText(), jDataTable1.getSelectedRow(), 5);
            jDataTable1.setValueAt(tbxHost.getText(), jDataTable1.getSelectedRow(), 6);
        }
        guardar = true;
        guardarExcel();
    }//GEN-LAST:event_btnGuardarActionPerformed

    private void btnModificarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnModificarActionPerformed
        tbxID.setText(jDataTable1.getValueAt(jDataTable1.getSelectedRow(),0).toString());
        tbxDirectorio.setText(jDataTable1.getValueAt(jDataTable1.getSelectedRow(),1).toString());
        tbxHora.setText(jDataTable1.getValueAt(jDataTable1.getSelectedRow(),2).toString());
        tbxBD.setText(jDataTable1.getValueAt(jDataTable1.getSelectedRow(),3).toString());
        tbxUsuario.setText(jDataTable1.getValueAt(jDataTable1.getSelectedRow(),4).toString());
        tbxPassword.setText(jDataTable1.getValueAt(jDataTable1.getSelectedRow(),5).toString());
        tbxHost.setText(jDataTable1.getValueAt(jDataTable1.getSelectedRow(),6).toString()); 
        guardar = false;
    }//GEN-LAST:event_btnModificarActionPerformed

    private void btnCancelarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnCancelarActionPerformed
        tbxID.setText("");
        tbxDirectorio.setText("");
        tbxHora.setText("");
        tbxBD.setText("");
        tbxUsuario.setText("");
        tbxPassword.setText("");
        tbxHost.setText("");
        guardar = true;
    }//GEN-LAST:event_btnCancelarActionPerformed

    private void btnNuevoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnNuevoActionPerformed
        tbxID.setText("");
        tbxDirectorio.setText("");
        tbxHora.setText("");
        tbxBD.setText("");
        tbxUsuario.setText("");
        tbxPassword.setText("");
        tbxHost.setText("");
        guardar = true;
    }//GEN-LAST:event_btnNuevoActionPerformed

    private void jDataTable1MouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jDataTable1MouseClicked
        // TODO add your handling code here:
        if(evt.getClickCount() == 2){
            tbxID.setText(jDataTable1.getValueAt(jDataTable1.getSelectedRow(),0).toString());
            tbxDirectorio.setText(jDataTable1.getValueAt(jDataTable1.getSelectedRow(),1).toString());
            tbxHora.setText(jDataTable1.getValueAt(jDataTable1.getSelectedRow(),2).toString());
            tbxBD.setText(jDataTable1.getValueAt(jDataTable1.getSelectedRow(),3).toString());
            tbxUsuario.setText(jDataTable1.getValueAt(jDataTable1.getSelectedRow(),4).toString());
            tbxPassword.setText(jDataTable1.getValueAt(jDataTable1.getSelectedRow(),5).toString());
            tbxHost.setText(jDataTable1.getValueAt(jDataTable1.getSelectedRow(),6).toString());  
            guardar = false;
        }
    }//GEN-LAST:event_jDataTable1MouseClicked

    private void btnEliminarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnEliminarActionPerformed
        // TODO add your handling code here:
        jDataTable1.removeRow(jDataTable1.getSelectedRow());
        guardarExcel();
    }//GEN-LAST:event_btnEliminarActionPerformed

    private void guardarExcel(){
        try {
            builder = factory.newDocumentBuilder();
            implementation = builder.getDOMImplementation();
            document = implementation.createDocument(null, "cnf", null);
            document.setXmlVersion("1.0");
            raiz = document.getDocumentElement();
            
            for (int i = 0; i < jDataTable1.getRows().size(); i++) {
                Element respaldo = document.createElement("respaldo");
                raiz.appendChild(respaldo);
                
                Element nodoNombreCampo = document.createElement("directorio"); //creamos un nuevo elemento
                Text nodoValorCampo = document.createTextNode(jDataTable1.getRowCell(i, "Directorio").toString()); //Ingresamos la info				
                nodoNombreCampo.appendChild(nodoValorCampo); 						
                respaldo.appendChild(nodoNombreCampo); //pegamos el elemento a la raiz "Documento"  
                
                nodoNombreCampo = document.createElement("hora"); //creamos un nuevo elemento
                nodoValorCampo = document.createTextNode(jDataTable1.getRowCell(i, "Hora").toString()); //Ingresamos la info				
                nodoNombreCampo.appendChild(nodoValorCampo); 						
                respaldo.appendChild(nodoNombreCampo); 
                
                nodoNombreCampo = document.createElement("db"); //creamos un nuevo elemento
                nodoValorCampo = document.createTextNode(jDataTable1.getRowCell(i, "DB").toString()); //Ingresamos la info				
                nodoNombreCampo.appendChild(nodoValorCampo); 						
                respaldo.appendChild(nodoNombreCampo);                 
                
                nodoNombreCampo = document.createElement("u"); //creamos un nuevo elemento
                nodoValorCampo = document.createTextNode(jDataTable1.getRowCell(i, "U").toString()); //Ingresamos la info				
                nodoNombreCampo.appendChild(nodoValorCampo); 						
                respaldo.appendChild(nodoNombreCampo); 
                                
                nodoNombreCampo = document.createElement("p"); //creamos un nuevo elemento
                nodoValorCampo = document.createTextNode(jDataTable1.getRowCell(i, "P").toString()); //Ingresamos la info				
                nodoNombreCampo.appendChild(nodoValorCampo); 						
                respaldo.appendChild(nodoNombreCampo); 
                                                
                nodoNombreCampo = document.createElement("host"); //creamos un nuevo elemento
                nodoValorCampo = document.createTextNode(jDataTable1.getRowCell(i, "Server").toString()); //Ingresamos la info				
                nodoNombreCampo.appendChild(nodoValorCampo); 						
                respaldo.appendChild(nodoNombreCampo); 
                                                                
                nodoNombreCampo = document.createElement("id"); //creamos un nuevo elemento
                nodoValorCampo = document.createTextNode(jDataTable1.getRowCell(i, "ID").toString()); //Ingresamos la info				
                nodoNombreCampo.appendChild(nodoValorCampo); 						
                respaldo.appendChild(nodoNombreCampo); 
            }
   
            Source source = new DOMSource(document);
            Result result = new StreamResult(new java.io.File("cnf.xml")); //nombre del archivo
            Transformer transformer = TransformerFactory.newInstance().newTransformer();
            transformer.transform(source, result);
            
            guardar = true;
            
            respaldos = Respaldo.GetRespaldos();
        } catch (ParserConfigurationException ex) {
            Logger.getLogger(FrmConfiguracion.class.getName()).log(Level.SEVERE, null, ex);
            System.out.println(ex.getMessage());
        } catch (TransformerConfigurationException ex) {
            Logger.getLogger(FrmConfiguracion.class.getName()).log(Level.SEVERE, null, ex);
            System.out.println(ex.getMessage());
        } catch (TransformerException ex) {
            Logger.getLogger(FrmConfiguracion.class.getName()).log(Level.SEVERE, null, ex);
            System.out.println(ex.getMessage());
        } 
    }
    
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton btnCancelar;
    private javax.swing.JButton btnEliminar;
    private javax.swing.JButton btnGuardar;
    private javax.swing.JButton btnModificar;
    private javax.swing.JButton btnNuevo;
    private javax.swing.JButton jButton2;
    private respaldomysql.jDataTable jDataTable1;
    private javax.swing.JInternalFrame jInternalFrame1;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JScrollPane jScrollPane3;
    private javax.swing.JScrollPane jScrollPane4;
    private javax.swing.JTable jTable1;
    private javax.swing.JTable jTable3;
    private javax.swing.JLabel lbDirectorio;
    private javax.swing.JLabel lbDirectorio1;
    private javax.swing.JLabel lbDirectorio10;
    private javax.swing.JLabel lbDirectorio11;
    private javax.swing.JLabel lbDirectorio12;
    private javax.swing.JLabel lbDirectorio13;
    private javax.swing.JLabel lbDirectorio2;
    private javax.swing.JLabel lbDirectorio3;
    private javax.swing.JLabel lbDirectorio4;
    private javax.swing.JLabel lbDirectorio5;
    private javax.swing.JLabel lbDirectorio6;
    private javax.swing.JLabel lbDirectorio7;
    private javax.swing.JLabel lbDirectorio8;
    private javax.swing.JLabel lbDirectorio9;
    private javax.swing.JTextField tbxBD;
    private javax.swing.JTextField tbxDirectorio;
    private javax.swing.JTextField tbxDirectorio10;
    private javax.swing.JTextField tbxDirectorio11;
    private javax.swing.JTextField tbxDirectorio6;
    private javax.swing.JTextField tbxDirectorio7;
    private javax.swing.JTextField tbxDirectorio8;
    private javax.swing.JTextField tbxDirectorio9;
    private javax.swing.JTextField tbxHora;
    private javax.swing.JTextField tbxHost;
    private javax.swing.JTextField tbxID;
    private javax.swing.JTextField tbxPassword;
    private javax.swing.JTextField tbxUsuario;
    // End of variables declaration//GEN-END:variables
}